package com.zhudi.develop_demo_as.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.Button;
import android.widget.EditText;

import com.zhudi.develop_demo_as.BaseActivity;
import com.zhudi.develop_demo_as.R;

import butterknife.Bind;
import butterknife.OnClick;

public class LoginActivity extends BaseActivity {
    private Context context;
    @Bind(R.id.etUserName)
    EditText etUserName;
    @Bind(R.id.etUserPassword)
    EditText etUserPassword;
    @Bind(R.id.btnlogin)
    Button btnlogin;

    @Override
    protected int getLayoutView() {
        return R.layout.activity_login;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        context = this;
        initView();
    }

    private void initView() {
        etUserName.addTextChangedListener(textWatcher);
        etUserPassword.addTextChangedListener(textWatcher);
        getSwipeBackLayout().setEnableGesture(false);
    }


    private TextWatcher textWatcher = new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            //String account = getEditText(etUserName);
            //String pwd = getEditText(etUserPassword);
//            if (ZhudiStrUtil.isEmpty(account) || ZhudiStrUtil.isEmpty(pwd)) {
//                btnlogin.setEnabled(false);
//            } else {
//                btnlogin.setEnabled(true);
//            }
        }
    };

    @OnClick(R.id.tvReigster)
    public void register(){
        startActivity(new Intent(context,RegisterActivity.class));
    }


}
